<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>获取属性</title>
</head>
<body>
    <div data-index="1"></div>
    <ul>
        <li>我是最原始的</li>
    </ul>
</body>
<script>
    var div =document.querySelector('div')
    console.log(div.getAttribute('data-index'));
    var ul =document.querySelector('ul')
    var li = document.createElement('li')
    li.innerHTML='插在后面的'
    ul.append(li)
    var li1 = document.createElement('li')
    li1.innerHTML='我是插在前面的'
    ul.insertBefore(li1,ul.children[0])
</script>
</html>